import java.util.Scanner;
public class Main {
    public static int getNixuNum(int num){
        String str = ""+num;
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = str.length()-1; i >=0; i--) {
            stringBuilder.append(str.charAt(i));
        }
        return Integer.valueOf(stringBuilder.toString());
    }
    public static void main(String[] args) {
        //从大于等于N的整数中找到一个一个最小的数M 使得M以及M的逆序数的和在100000 200000中
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        if(n>=200000 || n<1000){
            System.out.println("F");
            System.exit(0);
        }
        for (int i = n; ; i++) {
            int temp = getNixuNum(i);
            int sum = temp + i;
            if(sum>=100000 && sum<=200000) {
                System.out.println(i);
                break;
            }
        }


    }
}
